
var vm = new Vue({
    el: '#app',
    data:function(){
        return{
            pagename:"进度详情",
            common_fn:null,
            userinfo:null,
            assignHead:[
                {name:'批次号',property:'properties.mesproductionschedule__lotno','filters':[]},
                {name:'半成品名称',property:'properties.messemifinished__name','filters':[]},
                {name:'零部件名称',property:'properties.plmpart__name','filters':[]},
                {name:'物料编码',property:'properties.plmpart__materialno','filters':[]},
                {name:'图号',property:'properties.plmpart__identityno','filters':[]},
                {name:'工序名称',property:'properties.qcpprocess__name','filters':[]},
                {name:'派工班组',property:'properties.mesteam__name','filters':[]},
                {name:'工人',property:'properties.sysperson__name','filters':[]},
                {name:'派工数量',property:'properties.mesassignsheet__assignquantity','filters':[]},
                {name:'开始日期',property:'properties.mesassignsheet__startdate','filters':[]},
                {name:'完成日期',property:'properties.mesassignsheet__enddate','filters':[]}
            ],
            reportHead:[
                {name:'批次号',property:'properties.mesproductionschedule__lotno','filters':[]},
                {name:'半成品名称',property:'properties.messemifinished__name','filters':[]},
                {name:'零部件名称',property:'properties.plmpart__name','filters':[]},
                {name:'物料编码',property:'properties.plmpart__materialno','filters':[]},
                {name:'图号',property:'properties.plmpart__identityno','filters':[]},
                {name:'工序名称',property:'properties.qcpprocess__name','filters':[]},
                {name:'报工班组',property:'properties.mesteam__name','filters':[]},
                {name:'报工数量',property:'properties.mesreportsheet__realquantity','filters':[]},
                {name:'报工时间',property:'properties.mesreportsheet__reporttime','filters':[]},
                {name:'报工人',property:'properties.mesreportsheet__reportor','filters':[]},
                {name:'加工人',property:'properties.sysperson__name','filters':[]},
                {name:'是否协同',property:'properties.mesreportsheet__groupid','filters':[]}
            ],
            // 当前标签页显示
            activeName:'assign',
            // 派工单列表
            assignData:[],
            // 报工单列表
            reportData:[],
            // 参数
            param:null,
            assignloading:false,
            reportloading:false,
            
            // 当前选中项
            tempItem:null,
            
            //组件信息
            differentDialog:null,
            differentDialogItem:null,
        }
    },
    methods:{
        handleClick:function(tab){
            this.activeName = tab.name;
            this.getCount();
        },
        // 获取数据
        getCount:function(){
            var self = this;
            var queryFields,fn;
            if(self.activeName == 'assign'){
                self.assignloading = true;
                fn = 'Business_QueryAssignSheetOneSet';
                queryFields = [
                    {
                        "classType": "MesSemiFinished",
                        "propName": "name"
                    },
                    {
                        "classType": "MesProductionSchedule",
                        "propName": "lotno"
                    },
                    {
                        "classType": "PlmPart",
                        "propName": "name"
                    },
                    {
                        "classType": "PlmPart",
                        "propName": "MaterialNo"
                    },
                    {
                        "classType": "PlmPart",
                        "propName": "IdentityNo"
                    },
                    {
                        "classType": "QcpProcess",
                        "propName": "name"
                    },
                    {
                        "classType": "MesTeam",
                        "propName": "name"
                    },
                    {
                        "classType": "MesAssignSheet",
                        "propName": "AssignQuantity"
                    },
                    {
                        "classType": "MesAssignSheet",
                        "propName": "StartDate"
                    },
                    {
                        "classType": "MesAssignSheet",
                        "propName": "EndDate"
                    },
                    {
                        "classType": "SysPerson",
                        "propName": "Name"
                    }]; 
            }
            if(self.activeName == 'report'){
                self.reportloading = true;
                fn = 'Business_QueryReportSheetOneSet';
                queryFields = [
                    {
                        "classType": "MesSemiFinished",
                        "propName": "name"
                    },
                    {
                        "classType": "MesProductionSchedule",
                        "propName": "lotno"
                    },
                    {
                        "classType": "PlmPart",
                        "propName": "name"
                    },
                    {
                        "classType": "PlmPart",
                        "propName": "MaterialNo"
                    },
                    {
                        "classType": "PlmPart",
                        "propName": "IdentityNo"
                    },
                    {
                        "classType": "QcpProcess",
                        "propName": "name"
                    },
                    {
                        "classType": "MesTeam",
                        "propName": "name"
                    },
                    {
                        "classType": "MesReportSheet",
                        "propName": "RealQuantity"
                    },
                    {
                        "classType": "MesReportSheet",
                        "propName": "ReportTime"
                    },
                    {
                        "classType": "MesReportSheet",
                        "propName": "Reportor"
                    },
                    {
                        "classType": "SysPerson",
                        "propName": "name"
                    },
                    {
                        "classType": "MesReportSheet",
                        "propName": "GroupId"
                    }]
            }
            var param = {
                "filters": [
                    {
                        "classFlag": 0,
                        "classType": "MesSemiFinished",
                        "propName": "Product_OBJID",
                        "op": 4,
                        "propValue": getQueryString("productObjid"),
                        "propValue2": null,
                        "logic": 0,
                        "leftSplitter": 0,
                        "rightSplitter": 0,
                        "bAddWhereClauseFlag": true
                    },
                    {
                        "classFlag": 0,
                        "classType": "MesSemiFinished",
                        "propName": "objid",
                        "op": 4,
                        "propValue": getQueryString("semiFinishedObjid"),
                        "propValue2": null,
                        "logic": 0,
                        "leftSplitter": 0,
                        "rightSplitter": 0,
                        "bAddWhereClauseFlag": true
                    },
                    {
                        "classFlag": 0,
                        "classType": "MesTeam",
                        "propName": "name",
                        "op": 5,
                        "propValue": "",
                        "propValue2": null,
                        "logic": 0,
                        "leftSplitter": 0,
                        "rightSplitter": 0,
                        "bAddWhereClauseFlag": true
                    }
                ],
                "orderItems": [],
                "pageNum": 1000,
                "pageIndex": 1,
                "queryclasses": [],
                "queryFields": queryFields,
                "returnFormat": "0",
                "isQueryPreNext": false,
                "isQueryNextConsiderParent": false,
                "user": self.userinfo.user,
                "connectionId": 1,
                "appName": "MES",
                "factory": self.common_fn.configInfo.factory,
                "service": self.common_fn.configInfo.service
            }
            self.common_fn.invokeFun(fn,param,self.userinfo,function(response){
                if(response.resFlag == 0){
                    if(fn == 'Business_QueryAssignSheetOneSet'){
                        self.assignData = response.result;
                        pushFilterData('assignHead',self.assignHead,self.assignData);
                    }
                    if(fn == 'Business_QueryReportSheetOneSet'){
                        for (var i = 0; i < response.result.length; i++) {
                            response.result[i].properties.mesreportsheet__groupid = Number(response.result[i].properties.mesreportsheet__groupid) ? "协同" : "普通";
                        }
                        self.reportData = response.result;
                        pushFilterData('reportHead',self.reportHead,self.reportData);
                    }
                }else{
                    notify(response.errMsg,'error')
                }
                self.assignloading = false;
                self.reportloading = false;
            })
        }
    },
    created:function(){
        
    },
    mounted:function(){
        var self = this;
        self.common_fn = new common_fn();
        self.common_fn.init(function(){
            self.common_fn.UserInfo(function(response){
                if(response.user == null){
                    window.location.href = '../login.html?redirect=./report/progress.html';
                }
                self.userinfo = response;
                self.getCount()
            })
        });
    }
})
